package com.assignwork.modules.dailyshift;

import com.assignwork.dto.DailyShiftSearchDTO;
import com.assignwork.dto.GenerateShiftsDTO;
import com.assignwork.dto.ShiftRuleSearchDTO;
import com.assignwork.dto.ShiftRuleSubmitDTO;
import com.assignwork.service.IShiftRuleService;
import com.assignwork.vo.DailyShiftVO;
import com.assignwork.vo.ShiftRuleVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName ShiftRuleController
 * @Description 班组生成规则控制器
 * @Author dujianyu
 * @Date 2023/12/1 15:50
 */
@RestController
@AllArgsConstructor
@RequestMapping("shiftRule")
public class ShiftRuleController extends BladeController {

    private IShiftRuleService service;

    @PostMapping("submit")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增或修改", notes = "传入dto")
    public R<Boolean> submitShiftRule(@RequestBody ShiftRuleSubmitDTO dto) {
        return R.status(service.submitShiftRule(dto));
    }

    @PostMapping("generateNewShifts")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "生成新排班", notes = "传入dto")
    public R<Boolean> generateNewShifts(@RequestBody GenerateShiftsDTO dto) {
        return R.status(service.generateNewShifts(dto));
    }

    @PostMapping("example")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "示例", notes = "传入dto")
    public R<List<DailyShiftVO>> example(@RequestBody ShiftRuleSubmitDTO dto) {
        return R.data(service.getExample(dto));
    }

    @GetMapping("/page")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<IPage<ShiftRuleVO>> shiftRulePage(ShiftRuleSearchDTO dto, Query query) {
        return R.data(service.selectShiftRulePage(dto, Condition.getPage(query)));
    }

    @GetMapping("/list")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "列表", notes = "传入dto")
    public R<List<ShiftRuleVO>> shiftRulePage(ShiftRuleSearchDTO dto) {
        return R.data(service.selectShiftRuleList(dto));
    }

}
